﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css"  media="all">
    <script src="js/0_common/jquery.min.js"></script>
    <script src="js/constants.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<style>
    .fgsq .layui-form-select .layui-input {
        padding-right: 0 !important;
    }
    .ylbt {
        cursor: pointer;
    }
</style>
<body class="fgsq">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>企业复工复产服务</legend>
</fieldset>

<!--<form class="layui-form" lay-filter="form-test" action="" style="display: none" id="example" method="post">-->
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
        <legend>自动生成附件</legend>
        <div style="margin-left: 5%;margin-top: 1%">
            <button type="button" id="fgba"  class="layui-btn"  style="width: 250px;">自动生成企业复工信息表</button> <br/><br/><br/>
            <button type="button" id="rydj" class="layui-btn"  style="width: 250px;" >自动生成复工人员信息表</button> <br/><br/><br/>
            <button type="button" id="fwcb" class="layui-btn"  style="width: 250px;">自动生成企业防护物资储备情况表</button> <br/><br/>
        </div>
        <div style="margin-left: 5%;margin-top: 1%">
            <button type="button"  onclick="window.location.href = file + '企业疫情防控样例.docx';" class="layui-btn"  style="width: 250px;">下载企业疫情防控方案样例</button> <br/><br/><br/>
<!--            <button type="button" onclick="window.location.href = file + '企业疫情防控承诺书模板.docx';" class="layui-btn"  style="width: 250px;" >下载企业疫情防控承诺书模板</button><br/><br/><br/><br/><br/><br/>-->
        </div>



    <div class="layui-form-item">
        <div class="layui-input-block" style="margin-top: 1%">
<!--            <button type="button" class="layui-btn layui-btn-normal" id="baocun"   lay-filter="demo1"> 保  存 </button>-->
            <button class="layui-btn" id="next"  >下一步</button>
            <button type="reset" class="layui-btn layui-btn-primary"> 重  置 </button>
        </div>
    </div>
    </fieldset>
<!--</form>-->

<ul class="layui-timeline" style="display: block" id="time">

</ul>
<script src="layui/layui.js" charset="utf-8"></script>
<script src="js/constants.js"></script>
<script src="js/0_common/jquery.min.js"></script>
<script src="layui/jquery.serializejson.min.js"></script>
<script src="./data/area.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var ctx = Constants.path;
    var file = ctx+"FUGONGP/";
    var svcHeader = Constants.path
    var qyid = localStorage.getItem('qyid');
    $('#next').click(function () {
        window.location.href = "Fir_fjsc.html"
    });
    $("#fgba").unbind('click').click(function () {
        $.ajax({
            url:svcHeader+"pv/scb1?qyid="+qyid,
            type:'POST',
            success:function (data) {
                if(data.code=="200"){
                    window.location.href = file + data.msg;
                }else{
                    alert(data.msg)
                }
            }
        })
    })

    $("#rydj").unbind('click').click(function () {
        window.location.href=svcHeader+"ryxxs/export2?qyid="+qyid
        // $.ajax({
        //     url:svcHeader+"ryxxs/export?qyid="+qyid,
        //     type:'POST',
        //     success:function (data) {
        //         if(data.code=="200"){
        //             window.location.href = file + data.msg;
        //         }else{
        //             alert(data.msg)
        //         }
        //     }
        // })
    })

    $("#fwcb").unbind('click').click(function () {
        $.ajax({
            url:svcHeader+"pv/scb2?qyid="+qyid,
            type:'POST',
            success:function (data) {
                if(data.code=="200"){
                    window.location.href = file + data.msg;
                }else{
                    alert(data.msg)
                }
            }
        })
    })


    $("#ggyqyg").mouseover(function () {
        document.getElementById('ggyqwz').style.display=''
    }).mouseout(function () {
        document.getElementById('ggyqwz').style.display='none'
    });

    $("#ggyqfk").mouseover(function () {
        document.getElementById('ggyqfkwz').style.display=''
    }).mouseout(function () {
        document.getElementById('ggyqfkwz').style.display='none'
    });

    var currentEnterprise;
    layui.use(['form', 'layedit', 'laydate','upload'], function(){
        var qyid = localStorage.getItem('qyid');
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate,
            upload = layui.upload
        loadLouyu(function () {
            var str = "<option value=''>请选择</option>";
            for (let i=0; i<area.length;i++) {
                str += "<option value='" + area[i] + "'>" + area[i] + "</option>"
            }
            $('#zd56').append(str);
            layui.form.render('select','form-test');
        })
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            success: function(r) {
                if (r.code == "200"){
                    var data = r.data;
                    currentEnterprise = data;
                    $("#zd2").val(data.name)
                    $("#zd3").val(data.qu)
                    $("#zd22").val(data.street)
                    $("#zd4").val(data.address)
                    $("#zd5").val(data.faren)
                    $("#zd6").val(data.lxrphone)
                    $("#zd7").val(data.gsrenshu)
                    $("#zd56").each(function() {
                        // this代表的是<option></option>，对option再进行遍历
                        $(this).children("option").each(function() {
                            // 判断需要对那个选项进行回显
                            if (this.value == data.louyu) {
                                console.log($(this).text());
                                // 进行回显
                                $(this).attr("selected","selected");
                            }
                        });
                    })
                    // $.ajax({
                    //     type: "get",
                    //     url: ctx + "pb/qysqbs/findall",
                    //     data:{
                    //         "qyid":qyid
                    //     },
                    //     success: function(r) {
                    //         var str = "";
                    //         if (r.code == "200" && r.data.length > 0 ){
                    //             $.ajax({
                    //                 type: "get",
                    //                 url: ctx + "pb/shenhes/findall",
                    //                 data:{
                    //                     "qyid":qyid
                    //                 },
                    //                 success: function(r1) {
                    //                     var i = r.data.length-1;
                    //                     var timeStr = new Date(r.data[i].createtime).toLocaleString();
                    //                     str += "<li class=\"layui-timeline-item\">\n" +
                    //                         "        <i class=\"layui-icon layui-timeline-axis\">&#xe63f;</i>\n" +
                    //                         "        <div class=\"layui-timeline-content layui-text\">\n" +
                    //                         "            <h3 class=\"layui-timeline-title\">"+timeStr.substring(0,timeStr.length - 3)+"</h3>\n" +
                    //                         "            <p >\n" +
                    //                         "复工申请提交成功！<button type=\"button\" class=\"layui-btn layui-btn-warm\" onclick='ck(\""+r.data[i].id+"\")'>查看详情</button>\n";
                    //                     if (data.status == '1' ){
                    //                         str +=  "<button type=\"button\" class=\"layui-btn layui-btn-warm\" onclick='sb(\""+r.data[i].qyid+"\")'>上报</button>\n";
                    //                         str +=  "<button type=\"button\" class=\"layui-btn layui-btn-warm\" onclick='xg(\""+r.data[i].id+"\")'>修改</button>\n"
                    //                         str +="            </p>\n" +
                    //                             "        </div>\n" +
                    //                             "    </li>"
                    //                             + "<li class=\"layui-timeline-item\">\n" +
                    //                             "        <i class=\"layui-icon layui-timeline-axis\">&#xe63f;</i>\n" +
                    //                             "        <div class=\"layui-timeline-content layui-text\">\n" +
                    //                             "            <h4 class=\"layui-timeline-title\">待上报复工申请</h4>\n" +
                    //                             "            <p >\n" +
                    //                             "            </p>\n" +
                    //                             "        </div>\n" +
                    //                             "    </li>";
                    //                     }
                    //                     if (data.status == '2' ){
                    //                         str +="            </p>\n" +
                    //                             "        </div>\n" +
                    //                             "    </li>"
                    //                             + "<li class=\"layui-timeline-item\">\n" +
                    //                             "        <i class=\"layui-icon layui-timeline-axis\">&#xe63f;</i>\n" +
                    //                             "        <div class=\"layui-timeline-content layui-text\">\n" +
                    //                             "            <h4 class=\"layui-timeline-title\">已上报复工申请，待审核</h4>\n" +
                    //                             "            <p >\n" +
                    //                             "            </p>\n" +
                    //                             "        </div>\n" +
                    //                             "    </li>";
                    //                     }
                    //
                    //                     if (r1.code == "200" && r1.data.length > 0 ){
                    //                         $.each(r1.data,function (index,obj) {
                    //                             var tempStr = new Date(obj.shshijian).toLocaleString();
                    //                             str +=
                    //                                 "<li class=\"layui-timeline-item\">\n" +
                    //                                 "        <i class=\"layui-icon layui-timeline-axis\">&#xe63f;</i>\n" +
                    //                                 "        <div class=\"layui-timeline-content layui-text\">\n" +
                    //                                 "            <h3 class=\"layui-timeline-title\">"+ tempStr.substring(0, tempStr.length - 3)+"</h3>\n" +
                    //                                 "            <p >\n" +
                    //                                 "审核结果：" +obj.shenhejieguo +"</br>" +
                    //                                 "审核意见："+obj.shenheyijian+"</br>" +
                    //                                 "审核人："+obj.shren+"</br>" +
                    //                                 "            </p>\n" +
                    //                                 "        </div>\n" +
                    //                                 "    </li>";
                    //                         })
                    //                         if (data.status == '5' ){
                    //                             str +=  "<button type=\"button\" class=\"layui-btn layui-btn-warm\"  onclick='xg(\""+r.data[i].id+"\")'>修改</button>\n";
                    //                         }
                    //                     }
                    //                     $("#time").append(str)
                    //                 }
                    //             })
                    //             $("#time").css("display","block");
                    //         }else {
                    //             $("#example").css("display","block");
                    //
                    //         }
                    //     }
                    // });
                }
            }
        });


        upload.render({
            elem: '#test1'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf'
            ,ext: 'xls|xlsx|pdf|doc|docx'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input1").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test2'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf'
            ,ext: 'xls|xlsx|pdf|doc|docx'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input2").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test3'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf'
            ,ext: 'xls|xlsx|pdf|doc|docx'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input3").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test4'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf'
            ,ext: 'xls|xlsx|pdf|doc|docx'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input4").val(res.obj);
                }
            }
        });
        upload.render({
            elem: '#test55'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,acceptMime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/msword,application/vnd.ms-excel,application/pdf'
            ,ext: 'xls|xlsx|pdf|doc|docx'
            ,size:2048
            ,done: function(res){
                if (!res){
                    layer.msg('请勿上传空文件！');
                }else {
                    layer.msg('上传成功');
                    $("#input55").val(res.obj);
                }
            }
        });
        var test5 = "",test6 = "",test7 = "",test8 = "",test9 = "";
        upload.render({
            elem: '#test5'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,acceptMime: 'image/*',
            ext: 'jpg|png|gif|bmp|jpeg'
            ,multiple: true
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo5').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
                });
            }
            ,done: function(res){
                //上传完毕
                layer.msg('上传成功');
                if (test5 != ""){
                    test5 = test5 + "," + res.obj;
                }else {
                    test5 =  res.obj;
                }
            }
        });

        upload.render({
            elem: '#test6'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,multiple: true
            ,acceptMime: 'image/*',
            ext: 'jpg|png|gif|bmp|jpeg'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo6').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
                });
            }
            ,done: function(res){
                layer.msg('上传成功');
                if (test6 != ""){
                    test6 = test6 + "," + res.obj;
                }else {
                    test6 =  res.obj;
                }
            }
        });
        upload.render({
            elem: '#test7'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,multiple: true
            ,acceptMime: 'image/*',
            ext: 'jpg|png|gif|bmp|jpeg'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo7').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
                });
            }
            ,done: function(res){
                layer.msg('上传成功');
                if (test7 != ""){
                    test7 = test7 + "," + res.obj;
                }else {
                    test7 =  res.obj;
                }
            }
        });
        upload.render({
            elem: '#test8'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,multiple: true
            ,acceptMime: 'image/*',
            ext: 'jpg|png|gif|bmp|jpeg'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo8').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
                });
            }
            ,done: function(res){
                layer.msg('上传成功');
                if (test8 != ""){
                    test8 = test8 + "," + res.obj;
                }else {
                    test8 =  res.obj;
                }
            }
        });
        upload.render({
            elem: '#test9'
            ,url: ctx + 'file/fileUpload' //改成您自己的上传接口
            ,multiple: true
            ,acceptMime: 'image/*',
            ext: 'jpg|png|gif|bmp|jpeg'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo9').append('<img src="'+ result +'" alt="'+ file.name +'" style = "width: 200px;" class="layui-upload-img">')
                });
            }
            ,done: function(res){
                layer.msg('上传成功');
                if (test9 != ""){
                    test9 = test9 + "," + res.obj;
                }else {
                    test9 =  res.obj;
                }
            }
        });
        //日期
        laydate.render({
            elem: '#date'
        });
        laydate.render({
            elem: '#date1',
            value: new Date()
        });
        laydate.render({
            elem: '#date2',
            value: new Date()
        });

        //创建一个编辑器
        var editIndex = layedit.build('LAY_demo_editor');

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 1){
                    return '请填写内容！';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,content: function(value){
                if(value.length < 18){
                    return '信用代码填写不正确！';
                }
            }
        });

        // //监听提交
        // form.on('submit(demo1)', function(data){
        //     window.location.href = "Fir_fjsc.html"
        //     // var obj1 = $("#example").serializeJSON()
        //     // var obj = {};
        //     // obj.zd1 = obj1.zd1
        //     // obj.zd2 = obj1.zd2
        //     // obj.zd3 = obj1.zd3
        //     // obj.zd4 = obj1.zd4
        //     // obj.zd5 = obj1.zd5
        //     // obj.zd6 = obj1.zd6
        //     // obj.zd7 = obj1.zd7
        //     // obj.zd8 = obj1.zd8
        //     // obj.zd9 = obj1.zd9
        //     // obj.zd10 = obj1.zd10
        //     // obj.zd11 = obj1.zd11
        //     // obj.zd12 = obj1.zd12
        //     // obj.zd13 = obj1.zd13
        //     // obj.zd14 = obj1.zd14
        //     // obj.zd15 = obj1.zd15
        //     // obj.zd16 = obj1.zd16
        //     // obj.zd17 = test5;
        //     // obj.zd18 = test6;
        //     // obj.zd19 = test7;
        //     // obj.zd20 = test8;
        //     // obj.zd21 = test9;
        //     // obj.zd22 = obj1.zd22;
        //     //
        //     // obj.zd24 = obj1.zd24;
        //     // obj.zd25 = obj1.zd25
        //     // obj.zd26 = obj1.zd26
        //     // obj.zd27 = obj1.zd27
        //     // obj.zd28 = obj1.zd28
        //     // obj.zd29 = obj1.zd29
        //     // obj.zd30 = obj1.zd30
        //     // obj.zd31 = obj1.zd31
        //     // obj.zd32 = obj1.zd32
        //     // obj.zd33 = obj1.zd33
        //     // obj.zd34 = obj1.zd34
        //     // obj.zd35 = obj1.zd35
        //     // obj.zd36 = obj1.zd36
        //     // obj.zd37 = obj1.zd37
        //     // obj.zd38= obj1.zd38
        //     // obj.zd39 = obj1.zd39
        //     // obj.zd40 = obj1.zd40
        //     //
        //     // for (let i = 50; i <= 70; i++) {
        //     //     obj['zd' + i] = obj1['zd' + i];
        //     // }
        //     // obj.qyid = qyid;
        //     // $.ajax({
        //     //     type: "post",
        //     //     url: ctx + "pv/qysqbs",
        //     //     data: JSON.stringify(obj),
        //     //     dataType:"json",
        //     //     contentType:"application/json",
        //     //     success: function(r) {
        //     //         if (r.code == "200"){
        //     //             layer.msg('提交成功！', {
        //     //                 icon: 1,
        //     //                 time: 2000 //2秒关闭（如果不配置，默认是3秒）
        //     //             }, function(){
        //     //                 window.location.href = "Fir_fjsc.html"
        //     //             });
        //     //         }else {
        //     //             layer.msg('提交失败');
        //     //         }
        //     //     }
        //     // });
        //     // return false;
        // })

    });
    //上报
    function sb(qyid) {
        var updateStatus = currentEnterprise.sflouyu === '1' ? '2' : '3'
        $.ajax({
            type: "put",
            url: ctx + "pv/qyxxs/"+qyid,
            data: JSON.stringify({
                "status": updateStatus
            }),
            dataType:"json",
            contentType:"application/json",
            success: function(r) {
                if (r.code == "200"){
                    layer.msg('上报成功！', {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        window.location.href = "test.html"
                    });
                }else {
                    layer.msg('提交失败');
                }
            }
        });
    }

    //查看详情
    function ck(id) {
        layer.open({
            type: 2,
            title:"申报详情",
            content: 'testXq.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }

    //修改
    function xg(id) {
        layer.open({
            type: 2,
            title:"申报-修改",
            content: 'testXg.html?id='+id,
            offset: ['50px', '150px'],
            area: ['70%', '90%']
        });
    }
    checkStatus();
    function checkStatus(cb) {
        $.ajax({
            type: "get",
            url: ctx + "/pb/qyxxs/"+qyid,
            success: function(r) {
                if (r.code == "200"){
                    if (r.data.status >= 2) {
                        window.location.href = 'test.html'
                    } else {
                        if (cb) {
                            cb();
                        }
                    }
                }
            }
        });
    }


</script>

</body>
</html>
